﻿singleApp.controller('change_passwordUserCtrl', ['$http', '$scope', function ($http, $scope) {
    $scope.model = { id: window.singleConfig.id, newpas: "", new_con: "" };

    $scope.confirm = function () {

        if ($scope.model.newpas != $scope.model.new_con) {
            layer.msg("两次密码不一致！");
            return;
        }


        var api_url = window.singleConfig.rootUrl + 'api/admin/UsersService/changeUserPasssword';
        layer.load(2);
        $http({
            method: 'POST',
            url: api_url,
            data: $.param($scope.model),
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        })
		.then(function (result) {
		    var data = result.data;
		    if (data.code == "success") {
		        layer.closeAll();
		        layer.msg("更新成功！");
		    }
		    else {
		        layer.closeAll();
		        layer.msg(data.message);
		    }
		}, function (data) {
		    layer.msg("系统错误!");
		});

    };
}]);